package com.ruoyi.system.service.news.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.ruoyi.system.domain.news.NewsMainBusiness;
import com.ruoyi.system.domain.news.query.NewsMainBusinessQuery;
import com.ruoyi.system.domain.news.vo.NewsMainBusinessVo;
import com.ruoyi.system.domain.news.vo.NewsMainBusinessVo;
import com.ruoyi.system.mapper.news.NewsMainBusinessMapper;
import com.ruoyi.system.service.news.NewsMainBusinessService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Slf4j
public class NewsMainBusinessServiceImpl extends ServiceImpl<NewsMainBusinessMapper, NewsMainBusiness>
        implements NewsMainBusinessService {

    @Override
//    @DataScope(deptAlias = "t",userAlias = "t")
    public List<NewsMainBusinessVo> getNewsMainBusinessList(NewsMainBusinessQuery newsMainBusinessQuery) {
        if (newsMainBusinessQuery.getIfPage()) {
            PageHelper.startPage(newsMainBusinessQuery.getPageNum(), newsMainBusinessQuery.getPageSize());
        }
        List<NewsMainBusinessVo> newsMainBusinessVoList = baseMapper.getNewsMainBusinessList(newsMainBusinessQuery);
        if (!newsMainBusinessVoList.isEmpty() && newsMainBusinessQuery.getId() == null) {
            for (NewsMainBusinessVo newsMainBusinessVo:newsMainBusinessVoList) {
                newsMainBusinessVo.setContent(null);
            }
        }
        return newsMainBusinessVoList;
    }
}
